/* 
 * File:   main.cpp
 * Author: alexey
 *
 * Created on 19 Март 2011 г., 4:50
 */

#include <cstdlib>
#include <dlfcn.h>
#include "core/servicelocator.h"
#include "storage/storage.h"
#include "scanner/scanner.h"
#include "tracer/tracer.h"
#include <auto_ptr.h>
#include <iostream>

using namespace std;
using namespace storagemon;

/*
 * 
 */
int main(int argc, char** argv)
{
    if (argc > 0)
    {
        ServiceLocator sl(0);
        StorageServiceFactory sf;
        tracer tr;
        tr.Open("console");
        sl.RegisterService(STORAGE_FACTORY, static_cast<IService*>(&sf));
        sl.RegisterService(TRACER_SERVICE, static_cast<IService*>(&tr));
        sf.RegisterObject(FILEOBJECT, CreateStorageServiceFile);
        sf.RegisterObject(DIRECTORYOBJECT, CreateStorageServiceDirectory);
        sf.RegisterObject(STORAGEOBJECT, CreateStorageServiceStorage);

        auto_ptr<IStorage> storage;
        storage.reset(static_cast<IStorage*>(sf.CreateService(STORAGEOBJECT,
                "projects", "/home/alexey/projects", 0, 0, 0)));
        Scanner scan(storage.get(),
                static_cast<IServiceLocator*>(&sl));
        sl.RegisterService(SCANNER_SERVICE, &scan);
        scan.Tree();
        scan.Scan();
    }
    return 0;
}

